home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / utility / v11n02.zip / MATHDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1991-12-28  |  3KB  |  100 lines

  1. PROGRAM MathDemo;
  2. USES math;  { this is a demo on how to use Math.TPU }
  3.  
  4. VAR
  5.   X, Y  : Real;
  6.   c1, c2, c3, c4 : Complex;
  7.  
  8. BEGIN
  9.   WriteLn('Demo on using the sinh and cosh functions ');
  10.   Write('Enter a value from -10 to 10 : ');
  11.   ReadLn(X);
  12.   Y := Sinh(X);
  13.   WriteLn('sinh ', X:3:3, ' = ', Y:2:5);
  14.   Y := Cosh(X);
  15.   WriteLn('cosh ', X:3:3, ' = ', Y:2:5);
  16.   Y := Sqr(Cosh(X)) - Sqr(Sinh(X));
  17.   WriteLn('sqr(cosh ',X:3:3,') - sqr(sinh ',X:3:3,
  18.           ') = ',Y:2:5);
  19.   WriteLn('(should always be 1.00000)');
  20.   WriteLn;
  21.  
  22.   WriteLn('Here we are going to test the complex ',
  23.           'procedures. Enter complex numbers');
  24.   WriteLn('A + Bi and C + Di.  Press ENTER after ',
  25.           'each input.');
  26.   Write(' Enter A : ');
  27.   ReadLn(c1.R);
  28.   Write(' Enter B : ');
  29.   ReadLn(c1.I);
  30.   Write(' Enter C : ');
  31.   ReadLn(c2.R);
  32.   Write(' Enter D : ');
  33.   ReadLn(c2.I);
  34.  
  35.   c3.S := CmpAdd(c1, c2);
  36.   WriteLn(C2S(c1, 3, 3),' + ',C2S(c2, 3, 3), ' = ',
  37.           C2S(c3, 3, 3));
  38.  
  39.   c3.S := CmpSub(c1, c2);
  40.   WriteLn(C2S(c1, 3, 3),' - ',C2S(c2, 3, 3), ' = ',
  41.           C2S(c3, 3, 3));
  42.  
  43.   c3.S := RecToPol(c1);
  44.   WriteLn(C2S(c1, 3, 3), ' in polar form : ',
  45.           P2S(c3, 3, 3));
  46.   c3.S := RECtoPOL(c2);
  47.   WriteLn(C2S(c2, 3, 3),' in polar form : ',
  48.           P2S(c3, 3, 3));
  49.  
  50.   WriteLn;
  51.   c3.S := CmpDiv(c1, c2);
  52.   WriteLn(C2S(c1, 3, 3),' / ',C2S(c2, 3, 3), ' = ',
  53.           C2S(c3, 3, 3));
  54.   c4.S := CmpMul(c3, c2);
  55.   WriteLn('check: ',C2S(c3, 3, 3), ' * ',C2S(c2, 3, 3),
  56.           ' = ', C2S(c4, 3, 3));
  57.  
  58.   WriteLn;
  59.   c3.S := CmpMul(c1, c2);
  60.   WriteLn(C2S(c1, 3, 3),' * ',C2S(c2, 3, 3), ' = ',
  61.           C2S(c3, 3, 3));
  62.   c4.S := CmpDiv(c3, c2);
  63.   WriteLn('check: ',C2S(c3, 3, 3), ' / ',C2S(c2, 3, 3),
  64.           ' = ', C2S(c4, 3, 3));
  65.  
  66.   WriteLn;
  67.   WriteLn('Demo for complex exponential');
  68.   WriteLn('Enter each value for A + Bi');
  69.   Write('Enter A : ');
  70.   ReadLn(c1.R);
  71.   Write('Enter B : ');
  72.   ReadLn(c1.I);
  73.   c3.S := CmpExp(c1);
  74.   WriteLn('EXP',C2S(c1, 3, 3), ' = ', C2S(c3, 3, 3));
  75.   c1.R := 0;
  76.   c1.I := 2*pi;
  77.   c3.S := CmpExp(c1);
  78.   WriteLn('EXP(0 + 2'#227'i) = ', C2S(c3, 3, 3));
  79.   WriteLn('(should always be 1 + 0i)');
  80.  
  81.   WriteLn;
  82.   WriteLn('Demo for complex sinh and cosh function ');
  83.   WriteLn('Enter each value for A + j B ');
  84.   Write('Enter A : ');
  85.   ReadLn(c1.R);
  86.   Write('Enter B : ');
  87.   ReadLn(c1.I);
  88.  
  89.   c2.S := CmpSinh(c1);
  90.   WriteLn('sinh',C2S(c1,3,3),' = ', C2S(c2,3,3));
  91.   c3.S := CmpCosh(c1);
  92.   WriteLn('cosh',C2S(c1,3,3),' = ', C2S(c3,3,3));
  93.   c2.S := CmpMul(c2, c2);
  94.   c3.S := CmpMul(c3, c3);
  95.   c4.S := CmpSub(c3, c2);
  96.   WriteLn('Sqr(cosh',C2S(c1, 3, 3), ') - Sqr(sinh',
  97.           C2S(c1, 3, 3), ') = ', C2S(c4, 3, 3));
  98.   WriteLn('(should always be 1 + 0i)');
  99. END.
  100.